//
//  HomeViewModel.swift
//  WeiBoAPP
//
//  Created by ios001 on 2021/6/11.
//  Copyright © 2021 zxf. All rights reserved.
//

import UIKit
import YYModel
class HomeViewModel: ZFBaseViewModel {

  lazy var dataList = [HomeModel]()
        
    override init() {
        super.init()
    }
    
    override func loadDataHandle(handleBlock: @escaping (_ isSuccess:Bool) -> ()) {
            
//        for _ in 0..<10 {
//            let model = HomeModel.init()
//            dataList.append(model)
//        }
        
        
        let dataArr = getHomeListData()
//        在这个方法前面也要加 @objc
        for dic  in dataArr {
            let newModel = HomeModel.init()
            
            newModel.yy_modelSet(with: dic as! [AnyHashable : Any])
//            let newModel = HomeModel.yy_model(withJSON: dic as![AnyHashable:Any])
            
            dataList.append(newModel)
        }
        
        handleBlock(true)
    }
}


extension HomeViewModel {
    
    func getHomeListData() -> [Any] {
        
/**
         var module:String?   // 类型
         var title:String? // 标题
         var location:String? // 位置
         var hiddenModel:Bool = false
         */
        var list = [Any]()
        for _  in 0..<10 {
            let dic = ["module":"model1fdd","title":"标题dd","location":"1","url":"https://baidu.com"]
            list.append(dic)
        }
        
        return list
    }
    
}



